﻿Imports FinanceiroDAL.ModuloConexao
Public Class RelBancos
#Region "Itens"
    Private Sub rbativo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbativo.CheckedChanged
        If rbativo.Checked Then
            gerarelatrio("Bancos Ativos", "{vw_GenBancos.sta_codigo}=1")
        End If
    End Sub

    Private Sub rbinativo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbinativo.CheckedChanged
        If rbativo.Checked Then
            gerarelatrio("Bancos Inativos", "{vw_GenBancos.sta_codigo}=2")
        End If
    End Sub

    Private Sub rbtodos_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbtodos.CheckedChanged
        If (rbtodos.Checked) Then
            gerarelatrio("Relação de Bancos - Geral", "")
        End If

    End Sub
#End Region
#Region "Relatorio"
    Public Sub gerarelatrio(titulo As String, formula As String)
        Try
            Dim frm As New RelatoriosfinFRM
            Dim rpt As New BancosREL
            Try
                rpt.SetDatabaseLogon(usuario, senha)
                rpt.SetParameterValue(0, titulo)
                rpt.RecordSelectionFormula = formula
                frm.CrystalReportViewer2.ShowGroupTreeButton = False
                frm.CrystalReportViewer2.ReportSource = rpt
                frm.ShowDialog()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            frm.Dispose()
            rpt = Nothing
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Finally
        End Try
    End Sub
#End Region
End Class